.article{:style=>'float:left;margin-right:15px;'} ผู้ลงทะเบียนในหลักสูตรต่างๆ
%br
%center
  =link_to image_tag("excel_icon.gif"), {:controller=>'syllabus', :action=>'export_student', :syllabus_id=>@syllabus_id, :syllabus_opening_id=>@syllabus_opening_id, :ref_oode=>@ref_oode}

%table{:class=>'index'}
  %tr
    %th ชื่อ
    %th หลักสูตร
    %th เกรดรายวิชา (เกรดขั้นต่ำที่ผ่านหลักสูตร)
    %th ใบรับรอง
  - @result.each do |row|
    - if row.user_id
      %tr{:style=>"background-color:#{cycle('#ddd','#fff')};"}
        %td{:valign=>'top'}= "#{row.title}#{row.fname} #{row.lname}"
        %td{:valign=>'top'}= row.name
        %td{:valign=>'top'}
          - syllabus = Syllabus.find_by_id(row.syllabus_id)
          - syllabus.syllabus_course_mappers.each do |mapper|
            .item{:style=>"clear:both;color:#{cycle('#00f','#0a0')};"}
              .item{:style=>'float:left;width:85%'}
                = mapper.course.name
              .item{:style=>'float:right;text-align:center'}
                - registration_course = RegistrationCourse.find_by_sql("select min(grade) as grade from registration_courses inner join registrations on registration_courses.registration_id = registrations.id and registration_courses.course_id = "+mapper.course.id.to_s+" and registrations.user_id = "+row.user_id.to_s)
                - if registration_course.present? and registration_course[0].grade.present?
                  = registration_course[0].grade
                - else
                  = "- "
                - certificate_course_rule = CertificateCourseRule.find_by_sql("select minimum_grade from certificate_course_rules where syllabus_id = "+row.syllabus_id.to_s+" and course_id = "+mapper.course.id.to_s)
                - if certificate_course_rule.present?
                  = "(#{certificate_course_rule[0].minimum_grade})"
        %td{:valign=>'top', :style=>'width:10em;'}
          - certificates = Certificate.find_by_sql("select certificates.ref_code,certificates.c_status from certificates inner join registrations on certificates.registration_id = registrations.id inner join syllabus_openings on syllabus_openings.id = registrations.syllabus_opening_id inner join syllabuses on syllabuses.id = syllabus_openings.syllabus_id where syllabus_id = "+row.syllabus_id.to_s+" and registrations.user_id = "+row.user_id.to_s+" and certificates.ref_code is not null")
          - if certificates.present?
            .item= link_to certificates[0].ref_code, {:controller=>'syllabus', :action=>'print_certificate', :ref_code=>certificates[0].ref_code}, :target=>'_blank'
            -if certificates[0].c_status=='C'
              = "<font color='red'>ถูกเพิกถอนแล้ว</font>"